<template>
  <div>
    <div class="login-box">
      <h3 style="text-align: center;padding: 20px 0 0 0">登录</h3>
      <div style="padding: 10px;">
        <nut-input placeholder="请输入学号" v-model="formData.num" label="学号"/>
        <nut-input placeholder="请输入密码" v-model="formData.pwd" label="密码" type="password"/>
        <div style="margin: 20px">
          <nut-button block :loading="loading" type="primary" @click="login">登录</nut-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {Notify} from '@nutui/nutui';

export default {
  name: "login",
  data() {
    return {
      formData: {
        num: '201805002590',
        pwd: '@Shy2206034346'
      },
      loading: false
    }
  },
  methods: {
    login() {
      this.loading = true
      let that = this
      this.axios.post('api/user/login/', this.formData).then(res => {
        console.log(res);
        if (res.status === 0) {
          window.location = ''
        } else {
          Notify.danger(res.msg || '登录失败');
        }
        that.loading = false
      }).catch(() => {
        Notify.danger('登录失败');
        that.loading = false
      })
    }
  },
  mounted() {
  }
}
</script>

<style scoped>
.login-box {
  max-width: 350px;
  background-color: white;
  margin: 30vh auto auto auto;
  border-radius: 10px;
}

.nut-input {
  border: none;
}
</style>